package com.party.course.service.impl;

import java.util.List;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.hutool.core.date.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.party.course.mapper.CoachLevelInfoMapper;
import com.party.course.domain.CoachLevelInfo;
import com.party.course.service.ICoachLevelInfoService;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.party.common.utils.SecurityUtils;

/**
 * 教练等级Service业务层处理
 *
 * @author ruoyi
 * @date 2025-05-29
 */
@Service
public class CoachLevelInfoServiceImpl extends ServiceImpl<CoachLevelInfoMapper, CoachLevelInfo> implements ICoachLevelInfoService {
    @Autowired
    private CoachLevelInfoMapper coachLevelInfoMapper;

    /**
     * 查询教练等级
     *
     * @param id 教练等级主键
     * @return 教练等级
     */
    @Override
    public CoachLevelInfo view(String id) {
        return coachLevelInfoMapper.selectCoachLevelInfoById(id);
    }

    /**
     * 查询教练等级列表
     *
     * @param coachLevelInfo 教练等级
     * @return 教练等级
     */
    @Override
    public List<CoachLevelInfo> findList(CoachLevelInfo coachLevelInfo) {
        return coachLevelInfoMapper.selectCoachLevelInfoList(coachLevelInfo);
    }

    /**
     * 新增教练等级
     *
     * @param coachLevelInfo 教练等级
     * @return 结果
     */
    @Override
    public int add(CoachLevelInfo coachLevelInfo) {
        if (StrUtil.isNotEmpty(coachLevelInfo.getLevel())) {
            if ("1".equals(coachLevelInfo.getLevel())) {
                coachLevelInfo.setName("初级教练");
            }else if ("2".equals(coachLevelInfo.getLevel())) {
                coachLevelInfo.setName("中级教练");
            }else if ("3".equals(coachLevelInfo.getLevel())) {
                coachLevelInfo.setName("高级教练");
            }else if ("4".equals(coachLevelInfo.getLevel())) {
                coachLevelInfo.setName("最高级教练");
            }else if ("5".equals(coachLevelInfo.getLevel())){
                coachLevelInfo.setName("特级教练");
            }else {
                coachLevelInfo.setName("教练");
            }
        }
        coachLevelInfo.setId(IdUtil.simpleUUID());
        coachLevelInfo.setDelFlag("0");
        return coachLevelInfoMapper.insert(coachLevelInfo);
    }

    /**
     * 修改教练等级
     *
     * @param coachLevelInfo 教练等级
     * @return 结果
     */
    @Override
    public int updateEntity(CoachLevelInfo coachLevelInfo) {
        coachLevelInfo.setUpdateTime(DateUtil.date());
        return coachLevelInfoMapper.updateById(coachLevelInfo);
    }

    /**
     * 批量删除教练等级
     *
     * @param ids 需要删除的教练等级主键
     * @return 结果
     */
    @Override
    public int deleteIds(List<String> ids) {
        return coachLevelInfoMapper.deleteCoachLevelInfoByIds(ids);
    }

    /**
     * 删除教练等级信息
     *
     * @param id 教练等级主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return coachLevelInfoMapper.deleteCoachLevelInfoById(id);
    }
}
